home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_02_09 / 2n09053a < prev    next >
Text File  |  1991-08-02  |  19KB  |  443 lines

  1.         PAGE    ,132
  2.         TITLE   SCROLOCK -- Holds screen every page
  3.  
  4. COMMENT $
  5.         SCROLOCK.EXE -- Locks scrolling of screen
  6.  
  7.         Generate EXE file using the following commands:
  8.         MASM SCROLOCK;
  9.         LINK SCROLOCK;
  10.  
  11.         Load from CONFIG.SYS file by use of the command:
  12.         DEVICE=SCROLOCK.EXE followed by an optional line count
  13.         and an optional keyword ON. If no line count is given,
  14.         the CGA normal line count of 25 will be used. If the
  15.         keyword ON is used, Scroll-Lock will be turned on.
  16.  
  17.         Load at system command or from within AUTOEXEC.BAT.
  18.         Type: SCROLOCK followed by an optional line count and
  19.         an optional keyword ON as above.
  20.  
  21.         To use, toggle the Scroll-Lock key to activate and
  22.         deactivate. If active, the screen will fill to the 
  23.         bottom, then it will scroll until the line where the 
  24.         cursor was when the last key was struck is now at the
  25.         top of the screen, then it will freeze with the 
  26.         cursor in the bottom left corner. To get the next 
  27.         screen-full, hit any key. Note: The key will be used 
  28.         later, so if you want just another screen-full, hit 
  29.         the Alt or either Shift key.
  30.         $
  31.  
  32. ;       ************************************************************
  33. ;       *                                                          *
  34. ;       *               Dummy Device Driver Header                 *
  35. ;       *                                                          *
  36. ;       ************************************************************
  37.  
  38. CSEG    SEGMENT
  39.         ORG     0000H                   ; For all device drivers
  40.  
  41. Header          DD      -1              ; One device
  42.                 DW      08000H          ; Character device
  43. StratA          DW      Strat           ; Strategy entrance
  44. IntrA           DW      Intr            ; Interrupt entrance
  45.                 DB      'Scrolock'      ; 8 character dummy name
  46.  
  47. ;       ************************************************************
  48. ;       *                                                          *
  49. ;       *                     Resident data                        *
  50. ;       *                                                          *
  51. ;       ************************************************************
  52.  
  53. ;       ROM BIOS DATA AREAS
  54. ;       -------------------
  55. BIOS_DATA               SEGMENT AT 00040H
  56.                 ORG     00017H
  57. KB_FLAG         DB      ?
  58. SCROLL_STATE    EQU     010H
  59.                 ORG     00050H
  60.  
  61. CURSOR_POSN     DW      8 DUP(?)        ; 8 pages of cursor positions
  62. CURSOR_MODE     DW      ?               ; Current cursor mode setting
  63. ACTIVE_PAGE     DB      ?               ; Current page being displayed
  64. BIOS_DATA       ENDS
  65.  
  66. ;       RESIDENT DATA
  67. ;       -------------
  68. OldIntr09       DW      ?               ; Interrupt vector storage
  69.                 DW      ?
  70. OldIntr10       DW      ?
  71.                 DW      ?
  72. LineCount       DB      ?               ; Line counter
  73. OddEven         DB      0               ; CR sets even = 0
  74. MaxRows         DB      25              ; Maximum screen rows
  75.  
  76. ;       ************************************************************
  77. ;       *                                                          *
  78. ;       *                     Resident code                        *
  79. ;       *                                                          *
  80. ;       ************************************************************
  81.  
  82. ;       Intercept of Interrupt 10H -- BIOS Video Call
  83. ;       ---------------------------------------------
  84.  
  85.         ASSUME  CS:CSEG, DS:NOTHING, ES:NOTHING
  86. NewIntr10:
  87.         STI                             ; Allow interrupts
  88.         PUSH    DS                      ; Save registers
  89.         PUSH    ES
  90.         PUSH    AX
  91.         PUSH    BX
  92.         PUSH    CX
  93.         PUSH    AX
  94.         MOV     AX,SEG BIOS_DATA        ; Set ES = BIOS_DATA segment
  95.         MOV     ES,AX
  96.         POP     AX
  97.         PUSH    CS                      ; Set DS = CS
  98.         POP     DS
  99.         ASSUME  DS:CSEG, ES:BIOS_DATA
  100.         TEST    KB_FLAG,SCROLL_STATE    ; Scroll-Lock on?
  101.         JZ      ExitIntr10              ; No, not locked
  102.         CMP     AH,000H                 ; Change video mode?
  103.         JE      ClrScr                  ; Yes, stop at bottom
  104.         CMP     AX,00600H               ; Clear video screen?
  105.         JE      ClrScr                  ; Yes, stop at bottom
  106.         CMP     AX,00601H               ; Roll up one line?
  107.         JE      RollUp                  ; Yes, do that type
  108.         CMP     OddEven,002H            ; Is roll active?
  109.         JE      ExitIntr10              ; Yes, don't do cursor
  110.         CMP     AH,002H                 ; Cursor command?
  111.         JE      CurMov                  ; Yes, test what move
  112. ExitIntr10:
  113.         POP     CX                      ; Restore registers
  114.         POP     BX
  115.         POP     AX
  116.         POP     ES
  117.         POP     DS
  118.         ASSUME  DS:NOTHING, ES:NOTHING
  119.         JMP     DWORD PTR OldIntr10     ; Perform video request
  120.  
  121.  
  122.         ASSUME  DS:CSEG, ES:BIOS_DATA
  123. ClrScr:
  124.         MOV     AL,MaxRows
  125.         MOV     LineCount,AL            ; Do not allow any roll
  126.         MOV     OddEven,000H            ; Reset CR LF counter
  127.         JMP     ExitIntr10              ; Exit Intr svc.
  128.  
  129. RollUp:
  130.         CMP     CX,000H                 ; From first line?
  131.         JNE     ExitIntr10              ; No, exit
  132.         MOV     AL,MaxRows
  133.         CMP     DH,AL                   ; To last line?
  134.         JNE     ExitIntr10              ; No, exit
  135.         INC     LineCount               ; Yes, now count lines
  136.         MOV     OddEven,002H            ; Turn off cursor type
  137. RollLoop:
  138.         CMP     LineCount,AL            ; Maximum roll?
  139.         JA      RollLoop                ; Yes, loop until key pressed
  140.         JMP     ExitIntr10              ; No, roll some more
  141.  
  142. CurMov:
  143.         CMP     BH,ACTIVE_PAGE          ; Cursor for active page?
  144.         JNE     ExitIntr10              ; No, set for other page
  145.         MOV     BL,BH                   ; Get cursor pointer
  146.         SUB     BH,BH
  147.         SHL     BX,1
  148.         MOV     CX,[BX+CURSOR_POSN]     ; Get cursor position
  149.         CMP     CH,MaxRows              ; At bottom row?
  150.         JNE     ExitIntr10              ; No, don't do anything
  151.         OR      DL,DL                   ; To column 0?
  152.         JNE     ExitIntr10              ; No, exit
  153.         CMP     DH,MaxRows              ; To last line?
  154.         JNE     ExitIntr10              ; No, exit
  155.         OR      CL,CL                   ; From column 0?
  156.         JE      NotEven                 ; Yes, probably a LF
  157.         MOV     OddEven,000H            ; A CR for sure - even up
  158. NotEven:
  159.         NOT     OddEven                 ; Alternate CR LF
  160.         CMP     OddEven,000H            ; Probable LF?
  161.         JE      ExitIntr10              ; Yes, skip LFs
  162.         INC     LineCount               ; No, now count lines
  163.         CMP     LineCount,AL            ; Maximum roll?
  164.         JNA     ExitIntr10              ; No, roll some more
  165.         MOV     AH,002H                 ; Put cursor in corner
  166.         MOV     BH,ACTIVE_PAGE
  167.         PUSHF
  168.         CALL    DWORD PTR OldIntr10
  169.         MOV     AL,MaxRows              ; Needed for release
  170.         JMP     RollLoop                ; Loop as above
  171.  
  172. ;       Intrercept of Intrerrupt 9H -- Hardware Keyboard
  173. ;       ----------------------------------------------
  174.  
  175. NewIntr09:
  176.         ASSUME  DS:NOTHING, ES:NOTHING
  177.         PUSH    AX                      ; Save registers
  178.         IN      AL,060H                 ; Read scan code
  179.         TEST    AL,080H                 ; Key pressed?
  180.         JNE     ExitIntr09              ; No, exit
  181.         PUSH    BX                      ; Save registers
  182.  
  183.         PUSH    CX
  184.         PUSH    DX
  185.         PUSH    ES
  186.         MOV     AX,SEG BIOS_DATA        ; Set ES = BIOS_DATA segment
  187.         MOV     ES,AX
  188.         ASSUME  ES:BIOS_DATA
  189.         MOV     BL,ACTIVE_PAGE          ; Get cursor pointer
  190.